#ifndef NEWNODE_H
#define NEWNODE_H

#include <QDialog>
#include <QList>
#include <QMessageBox>

namespace Ui {
class NewNode;
}

typedef struct _ARTICLE_ {
    int id;
    int type;
    int article_id;
    int parent_node_id;
    int combo_index;
    QString name;
    QList<struct _ARTICLE_> article_list;
} Article;

class NewNode : public QDialog
{
    Q_OBJECT

    QList<Article> article;

public:
    explicit NewNode(QWidget *parent = 0);
    ~NewNode();

    void set_article_list(QList<Article> article);

protected:
    void showEvent(QShowEvent*);

signals:
    void send_node(int article_id, int parent_node_id, QString title, QString content);

private slots:
    void on_save_button_clicked();

private:
    Ui::NewNode *ui;
    int sub_node(int level, QList<Article> article_list);
    Article article_at(int index, QList<Article> article);
};

#endif // NEWNODE_H
